//
//  TempViewController.swift
//  股票框架
//
//  Created by 李小骥 on 2017/10/12.
//  Copyright © 2017年 李小骥. All rights reserved.
//

import UIKit

class TempViewController: UIViewController {
    var urlstr:String = ""
    var para:[String:String] = [:]
    override func viewDidLoad() {
        super.viewDidLoad()
        let wv = UIWebView(frame: UIScreen.main.bounds)
        self.view.addSubview(wv)
        var str = urlstr
        if(para.isEmpty == false){
            for (key,value) in para{
                str.append("/"+"\(key)"+"/"+"\(value)")
            }
        }
        let url = URL(string: str)
        let request = URLRequest(url: url!)
        wv.loadRequest(request)

        // Do any additional setup after loading the view.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    override func viewWillAppear(_ animated: Bool) {
//        navigationController?.navigationBar.setBackgroundColor(.APP)
//        navigationController?.navigationBar.titleTextAttributes = (naviBarTitleAttributes as! [NSAttributedStringKey : Any])
        makeReturnButton()
    }
    func makeReturnButton(){
        let leftButtonView = UIView(frame: CGRect(x: 0, y: 0, width: 60, height: 40))
        let leftButton = UIButton(type: .system)
        leftButton.backgroundColor = .clear
        leftButton.frame = leftButtonView.frame
        leftButton.setImage(UIImage(named:"左侧返回"), for: .normal)
        leftButton.setTitle(RETURNBUTTONTITLEMARGIN+"我的", for: .normal)
        leftButton.tintColor = .white
        leftButton.autoresizesSubviews = true
        leftButton.contentHorizontalAlignment = .left
        leftButton.autoresizingMask = UIViewAutoresizing(rawValue: (UIViewAutoresizing.flexibleWidth.rawValue | UIViewAutoresizing.flexibleLeftMargin.rawValue))
        
        leftButton.contentEdgeInsets = UIEdgeInsets(top: 0, left: -15, bottom: 0, right: 0)
        leftButton.addTarget(self, action: #selector(backNative), for: .touchUpInside)
        leftButtonView.addSubview(leftButton)
        let leftBarButton = UIBarButtonItem(customView: leftButtonView)
        navigationItem.leftBarButtonItem = leftBarButton
    }
    @objc func backNative(){
        navigationController?.dismiss(animated: true, completion: nil)
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
